﻿using System.Text;

namespace AzureContrib.WindowsAzure.Tests.Utils
{
	/// <summary>
	/// A trace message 
	/// </summary>
	public class TraceMessage
	{
		public object MessageObject;
		public string Message;
		public string Category;
		public string Method;
		public string Format;
		public object[] Args;

		public static implicit operator string(TraceMessage traceMessage)
		{
			var result = new StringBuilder()
				.AppendFormat("Method: {0}", traceMessage.Method).AppendLine()
				.AppendFormat("Category: {0}", traceMessage.Category).AppendLine()
				.AppendFormat("Message: {0}", traceMessage.Message).AppendLine()
				.AppendFormat("Message object: {0}", traceMessage.MessageObject).AppendLine()
				.AppendFormat("Format: {0}", traceMessage.Format).AppendLine();

			if (traceMessage.Args != null)
			{
				foreach (var arg in traceMessage.Args)
				{
					result.AppendFormat("Arg: {0}", arg).AppendLine();
				}
			}
			return result.ToString();
		}
	}
}